#!/bin/sh

# Warning, problems can occur if the device restarts in the middle of this uci-default script

if [ -x /bin/sysrepoctl ]; then
	match=$(sysrepoctl -l | grep "ietf-netconf-notifications ")
	if [ ! "$match" ]; then
		sysrepoctl --install --yang=/etc/sysrepo/yang/ietf-netconf-notifications.yang -p 666
	fi

	match=$(sysrepoctl -l | grep "ietf-netconf-with-default ")
	if [ ! "$match" ]; then
		sysrepoctl --install --yang=/etc/sysrepo/yang/ietf-netconf-with-defaults.yang -p 666
	fi

	match=$(sysrepoctl -l | grep "ietf-origin ")
	if [ ! "$match" ]; then
		sysrepoctl --install --yang=/etc/sysrepo/yang/ietf-origin.yang -p 644
	fi

	match=$(sysrepoctl -l | grep "sysrepo ")
	if [ ! "$match" ]; then
		sysrepoctl --install --yang=/etc/sysrepo/yang/sysrepo.yang -p 600
	fi

	match=$(sysrepoctl -l | grep "ietf-netconf ")
	if [ ! "$match" ]; then
		sysrepoctl --install --yang=/etc/sysrepo/yang/ietf-netconf.yang -p 600
	fi
	sysrepoctl -m ietf-netconf -e writable-running
	sysrepoctl -m ietf-netconf -e candidate
	sysrepoctl -m ietf-netconf -e rollback-on-error
	sysrepoctl -m ietf-netconf -e validate
	sysrepoctl -m ietf-netconf -e startup
	sysrepoctl -m ietf-netconf -e xpath
fi

exit 0
